<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="description" content="课程表管理系统 - 支持学生管理、课程管理、课表安排和多课表混合显示的前端应用" />
  <meta name="keywords" content="课程表,学生管理,课程管理,教育管理,课程安排,React,TypeScript" />
  <meta name="author" content="Course Schedule System Team" />
  <meta name="theme-color" content="#1890ff" />
  
  <!-- PWA相关meta标签 -->
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="default" />
  <meta name="apple-mobile-web-app-title" content="课程表管理系统" />
  
  <!-- 防止缓存问题 -->
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="0" />
  
  <!-- 预连接到外部资源 -->
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  
  <!-- 图标 -->
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
  
  <!-- 预加载关键资源 -->
  <link rel="preload" href="/fonts/chinese.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
  
  <title>课程表管理系统</title>
  
  <!-- 内联关键CSS（防止FOUC） -->
  <style>
    /* 防止无样式内容闪烁 */
    html {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
      line-height: 1.5;
      -webkit-text-size-adjust: 100%;
      -webkit-tap-highlight-color: transparent;
    }
    
    body {
      margin: 0;
      padding: 0;
      background-color: #f5f5f5;
      color: #262626;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }
    
    * {
      box-sizing: border-box;
    }
    
    /* 加载状态样式 */
    #root {
      min-height: 100vh;
    }
    
    .app-loading {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100vh;
      background-color: #f5f5f5;
    }
    
    .loading-spinner {
      width: 40px;
      height: 40px;
      border: 4px solid #f0f0f0;
      border-top: 4px solid #1890ff;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin-bottom: 16px;
    }
    
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    
    .loading-text {
      color: #666;
      font-size: 14px;
      margin-bottom: 8px;
    }
    
    .loading-progress {
      width: 200px;
      height: 4px;
      background-color: #f0f0f0;
      border-radius: 2px;
      overflow: hidden;
    }
    
    .loading-progress-bar {
      height: 100%;
      background-color: #1890ff;
      border-radius: 2px;
      animation: progress 2s ease-in-out infinite;
    }
    
    @keyframes progress {
      0% { width: 0%; }
      50% { width: 70%; }
      100% { width: 100%; }
    }
    
    /* 错误状态样式 */
    .app-error {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100vh;
      padding: 20px;
      text-align: center;
      background-color: #f5f5f5;
    }
    
    .error-icon {
      font-size: 48px;
      color: #ff4d4f;
      margin-bottom: 16px;
    }
    
    .error-title {
      font-size: 24px;
      font-weight: 600;
      color: #ff4d4f;
      margin-bottom: 8px;
    }
    
    .error-message {
      color: #666;
      margin-bottom: 24px;
      max-width: 400px;
      line-height: 1.5;
    }
    
    .error-button {
      padding: 10px 20px;
      background-color: #1890ff;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 14px;
      transition: background-color 0.3s;
    }
    
    .error-button:hover {
      background-color: #40a9ff;
    }
    
    /* 无障碍支持 */
    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }
    
    /* 高对比度模式支持 */
    @media (prefers-contrast: high) {
      body {
        background-color: white;
        color: black;
      }
      
      .loading-spinner {
        border-color: #000;
        border-top-color: #0000ff;
      }
      
      .loading-progress-bar {
        background-color: #0000ff;
      }
    }
    
    /* 深色模式支持 */
    @media (prefers-color-scheme: dark) {
      body {
        background-color: #141414;
        color: #ffffff;
      }
      
      .app-loading,
      .app-error {
        background-color: #141414;
      }
      
      .loading-text,
      .error-message {
        color: #a6a6a6;
      }
      
      .loading-spinner {
        border-color: #434343;
        border-top-color: #177ddc;
      }
      
      .loading-progress {
        background-color: #434343;
      }
      
      .loading-progress-bar {
        background-color: #177ddc;
      }
    }
    
    /* 减少动画模式 */
    @media (prefers-reduced-motion: reduce) {
      .loading-spinner {
        animation: none;
      }
      
      .loading-progress-bar {
        animation: none;
        width: 100%;
      }
      
      * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
      }
    }
  </style>
</head>
<body>
  <!-- 应用根节点 -->
  <div id="root">
    <!-- 初始加载状态 -->
    <div class="app-loading">
      <div class="loading-spinner" aria-label="加载中"></div>
      <div class="loading-text">课程表管理系统启动中...</div>
      <div class="loading-progress">
        <div class="loading-progress-bar"></div>
      </div>
      <div class="sr-only">正在加载应用，请稍候</div>
    </div>
  </div>
  
  <!-- 不支持JavaScript的提示 -->
  <noscript>
    <div class="app-error">
      <div class="error-icon">⚠️</div>
      <div class="error-title">需要启用JavaScript</div>
      <div class="error-message">
        课程表管理系统需要JavaScript才能正常运行。<br>
        请在浏览器设置中启用JavaScript，然后刷新页面。
      </div>
    </div>
  </noscript>
  
  <!-- 应用脚本 -->
  <script type="module" src="/src/main.tsx"></script>
  
  <!-- 错误处理脚本 -->
  <script>
    // 全局错误处理
    window.addEventListener('error', function(event) {
      console.error('页面错误:', event.error);
      
      // 如果React应用加载失败，显示错误页面
      if (event.filename && event.filename.includes('main.tsx')) {
        document.getElementById('root').innerHTML = `
          <div class="app-error">
            <div class="error-icon">❌</div>
            <div class="error-title">应用加载失败</div>
            <div class="error-message">
              抱歉，应用加载时发生了错误。<br>
              请检查网络连接或尝试刷新页面。
            </div>
            <button class="error-button" onclick="window.location.reload()">
              重新加载
            </button>
          </div>
        `;
      }
    });
    
    // 未处理的Promise拒绝
    window.addEventListener('unhandledrejection', function(event) {
      console.error('未处理的Promise拒绝:', event.reason);
    });
    
    // 应用信息
    window.__APP_CONFIG__ = {
      title: '课程表管理系统',
      version: '1.0.0',
      env: 'development',
      debug: true
    };
    
    // 性能监控
    if ('performance' in window) {
      window.__PERFORMANCE_MONITOR__ = {
        mark: function(name) {
          performance.mark(name);
        },
        measure: function(name, startMark, endMark) {
          performance.measure(name, startMark, endMark);
        }
      };
      
      // 标记页面开始加载
      performance.mark('page-start');
    }
    
    // 页面加载完成后的处理
    window.addEventListener('load', function() {
      if (window.__PERFORMANCE_MONITOR__) {
        window.__PERFORMANCE_MONITOR__.mark('page-end');
        window.__PERFORMANCE_MONITOR__.measure('page-load-time', 'page-start', 'page-end');
      }
      
      console.log('📊 页面加载完成');
    });
  </script>
</body>
</html>